package com.heima.schedule.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * mybatis +配置
 *
 * @author DiXiaoNie
 * @date 2022/12/24
 * @since 2022/12/24 20:10
 */
@Configuration
public class MybatisPlusConfig {

    /**
     * 乐观锁拦截器
     *
     * @return {@link MybatisPlusInterceptor }
     * @author DiXiaoNie
     * @date 2022/12/24
     */
    @Bean
    public MybatisPlusInterceptor optimisticLockerInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        return interceptor;
    }
}
